package Dome01;

public class Test {
    public static void main (String[] args) throws CloneNotSupportedException {
        Animal animal = new Animal("张三",1,1);
        Animal animal1 = (Animal) animal.clone();
        System.out.println(animal);
        System.out.println(animal1);
    }
}

class Animal implements Cloneable{
    String name;
    int height;
    int weight;

    public Animal(String name, int height, int weight) {
        this.name = name;
        this.height = height;
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", height=" + height +
                ", weight=" + weight +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
